<style scoped>
</style>
<template>
  <HeaderSlot>
    <van-nav-bar :title="$t(this_action.label)" left-arrow @click-left="href_handle(-1)" />
  </HeaderSlot>
  <component v-if="template" :is="template" :model="model" :this_action="this_action" is_admin />
</template>

<script>
import edit_common from '@/components/model_base/edit_common.vue'
import edit_order from '@/components/model_base/edit_order.vue'
import refund_apply from '@/components/model_base/refund_apply.vue'
import HeaderSlot from "@/components/slot/HeaderSlot.vue";
import {_get, href_handle} from "@/vue_plugin/router_auto.js";
import {msg} from "@/js/vant_tool.js";
import {S94Model} from "@/js/S94Model.js";

export default {
  components: {HeaderSlot, edit_common, edit_order, refund_apply},
  data(){
    return {
      model_name: _get('model_name'),
      action: _get('action','edit'),
      model: {},
      this_action: {},
      template: '',
    }
  },
  methods:{},
  computed:{},
  mounted(){
    let model = S94Model.find(this.model_name);
    if (!model) {
      msg(`参数错误：model_name=${this.model_name}`);
      return href_handle(-1, 1500);
    }
    this.model = model;
    if (!model.action_map[this.action]) {
      msg(`参数错误：action=${this.action}`);
      return href_handle(-1, 1500);
    }
    this.this_action = model.action_map[this.action];

    let def_template = this.this_action.type === 'refund_apply' ? 'refund_apply' : (this.model.switch_pay ? 'edit_order' : 'edit_common');
    this.template = this.this_action.template || this.this_action.config.template || def_template;

  }
}
</script>